package com.dayang.redbook.user.biz.constant;

/**
 * @author: dayang
 * @since: 2024/5/23
 * @description: redis key常量
 */
public class RedisKeyConstants {

    /**
     * 小红书全局ID生成器KEY
     */
    public static final String REDBOOK_ID_GENERATOR_KEY = "redbook.id.generator";

    /**
     * 用户角色数据 KEY 前缀
     */
    private static final String USER_ROLES_KEY_PREFIX = "user:roles:";

    private static final String ROLE_PERMISSIONS_KEY_PREFIX = "role:permissions:";

    /**
     * 用户信息数据 KEY 前缀
     */
    private static final String USER_INFO_KEY_PREFIX = "user:info:";


    public static String buildUserInfoKey(Long userId) {
        return USER_INFO_KEY_PREFIX + userId;
    }


    /**
     * 构建用户角色 KEY
     * @param userId 用户id
     * @return
     */
    public static String buildUserRoleKey(long userId) {
        return USER_ROLES_KEY_PREFIX + userId;
    }

    public static String buildRolePermissionsKey(String roleKey) {
        return ROLE_PERMISSIONS_KEY_PREFIX + roleKey;
    }
}
